Queue
Operates on a First In, First Out (FIFO) principle
Stack
Operates on a Last In, Last Out (LIFO) principle
Bubble Sort
Bubble Sort Visualizer
Selection Sort
Selection Sort Visualizer
Merge Sort
Merge Sort Visualizer
Sliding Window Sort
Sliding Window Visualizer
Binary Search
Binary Search Visualizer
Linked List
Linked List Visualizer
Quick Sort
Quick Sort Visualizer
Two Pointer Sort
Two Pointer Visualizer
Sieve of Eratosthenes
Sieve of Eratosthenes Visualizer
Merge Sort Visualization
OVERVIEW
Merge sort is a sorting algorithm that follows the divide-and-conquer approach. It works by recursively dividing the input array into smaller subarrays and sorting those subarrays then merging them back together to obtain the sorted array.
Working
Divide: Divide the list or array recursively into two halves until it can no more be divided.
Conquer: Each subarray is sorted individually using the merge sort algorithm.
Merge: The sorted subarrays are merged back together in sorted order. The process continues until all elements from both subarrays have been merged.
Complexity
Time Complexity: O(nlogn)
Reason: At each step, we divide the whole array, for that logn and we assume n steps are taken to get sorted array, so overall time complexity will be nlogn.
Space Complexity: O(n)
Reason: We are using a temporary array to store elements in sorted order.